MutableCollection

interface MutableCollection<E> : Collection<E> , MutableIterable<E>

A generic collection of elements that supports adding and removing elements.

Parameters

E

the type of elements contained in the collection. The mutable collection is invariant in its element type.

Functions

add
Link copied to clipboard
abstract fun add(element: E): Boolean

Adds the specified element to the collection.

addAll
Link copied to clipboard
abstract fun addAll(elements: Collection<E>): Boolean

Adds all of the elements of the specified collection to this collection.

clear
Link copied to clipboard
abstract fun clear()

Removes all elements from this collection.

contains
Link copied to clipboard
abstract operator fun contains(element: E): Boolean
containsAll
Link copied to clipboard
abstract fun containsAll(elements: Collection<E>): Boolean
isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
iterator
Link copied to clipboard
abstract operator override fun iterator(): MutableIterator<E>
remove
Link copied to clipboard
abstract fun remove(element: E): Boolean

Removes a single instance of the specified element from this collection, if it is present.

removeAll
Link copied to clipboard
abstract fun removeAll(elements: Collection<E>): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

retainAll
Link copied to clipboard
abstract fun retainAll(elements: Collection<E>): Boolean

Retains only the elements in this collection that are contained in the specified collection.

Properties

size
Link copied to clipboard
abstract val size: Int

Inheritors

MutableList
Link copied to clipboard
MutableSet
Link copied to clipboard
AbstractMutableCollection
Link copied to clipboard

Extensions

addAll
Link copied to clipboard
fun <T> MutableCollection<in T>.addAll(elements: Iterable<T>): Boolean

Adds all elements of the given elements collection to this MutableCollection.

fun <T> MutableCollection<in T>.addAll(elements: Sequence<T>): Boolean

Adds all elements of the given elements sequence to this MutableCollection.

fun <T> MutableCollection<in T>.addAll(elements: Array<out T>): Boolean

Adds all elements of the given elements array to this MutableCollection.

minusAssign
Link copied to clipboard
inline operator fun <T> MutableCollection<in T>.minusAssign(element: T)

Removes a single instance of the specified element from this mutable collection.

inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Iterable<T>)

Removes all elements contained in the given elements collection from this mutable collection.

inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Array<T>)

Removes all elements contained in the given elements array from this mutable collection.

inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Sequence<T>)

Removes all elements contained in the given elements sequence from this mutable collection.

plusAssign
Link copied to clipboard
inline operator fun <T> MutableCollection<in T>.plusAssign(element: T)

Adds the specified element to this mutable collection.

inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Iterable<T>)

Adds all elements of the given elements collection to this mutable collection.

inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Array<T>)

Adds all elements of the given elements array to this mutable collection.

inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Sequence<T>)

Adds all elements of the given elements sequence to this mutable collection.

remove
Link copied to clipboard
inline fun <T> MutableCollection<out T>.remove(element: T): Boolean

Removes a single instance of the specified element from this collection, if it is present.

removeAll
Link copied to clipboard
inline fun <T> MutableCollection<out T>.removeAll(elements: Collection<T>): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

fun <T> MutableCollection<in T>.removeAll(elements: Iterable<T>): Boolean

Removes all elements from this MutableCollection that are also contained in the given elements collection.

fun <T> MutableCollection<in T>.removeAll(elements: Sequence<T>): Boolean

Removes all elements from this MutableCollection that are also contained in the given elements sequence.

fun <T> MutableCollection<in T>.removeAll(elements: Array<out T>): Boolean

Removes all elements from this MutableCollection that are also contained in the given elements array.

retainAll
Link copied to clipboard
inline fun <T> MutableCollection<out T>.retainAll(elements: Collection<T>): Boolean

Retains only the elements in this collection that are contained in the specified collection.

fun <T> MutableCollection<in T>.retainAll(elements: Iterable<T>): Boolean

Retains only elements of this MutableCollection that are contained in the given elements collection.

fun <T> MutableCollection<in T>.retainAll(elements: Array<out T>): Boolean

Retains only elements of this MutableCollection that are contained in the given elements array.

fun <T> MutableCollection<in T>.retainAll(elements: Sequence<T>): Boolean

Retains only elements of this MutableCollection that are contained in the given elements sequence.